import { PageParams } from '@/api/model/pageParams';
import { request } from '@/utils/request';

const page = async (params: PageParams) => {
  return request.post({
    url: '/user/page',
    data: params,
  });
};

const insertApi = async (data: any) => {
  return request.post({
    url: '/user/insert',
    data,
  });
};

const updateApi = async (data: any) => {
  return request.post({
    url: '/user/update',
    data,
  });
};

const deleteById = async (id: string) => {
  return request.get({
    url: `/user/delete/${id}`,
  });
};

const getRoleList = async () => {
  return request.get({
    url: '/user/roleList',
  });
};

// 重置密码
const resetPasswordApi = async (id: string) => {
  return request.get({
    url: `/user/resetPassword/${id}`,
  });
};

// 修改密码
const updatePasswordApi = async (data: any) => {
  return request.post({
    url: `/user/updatePassword`,
    data,
  });
};

export { deleteById, getRoleList, insertApi, page, resetPasswordApi, updateApi, updatePasswordApi };
